local lanhai = fk.CreateSkill {

  name = "joy__lanhai",

  tags = { Skill.Compulsory, },

}



lanhai:addEffect(fk.TurnEnd, {
  name = "joy__lanhai",
  anim_type = "drawcard",
  events = {fk.TurnEnd},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(lanhai.name) and player.room:getBanner("joy_lunce-turn") and player.room:getBanner("joy_lunce-turn") == 1
  end,
  on_cost = function(self, event, target, player, data)
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local a,b = false,false
    if player.room:getBanner("joy_lunce_vic") and player.room:getBanner("joy_lunce_vic") == 1 then
      a = true
    end
    if player.room:getBanner("joy_lunce_novic") and player.room:getBanner("joy_lunce_novic") == 1 then
      b = true
    end
    if a then
      if player:getMark("@joy_lanhai-round") > 0 then
        player:drawCards(math.min(3,player:getMark("@joy_lanhai-round")),lanhai.name)
      end
      if not player.dead then
        player.room.logic:trigger("fk.joy_lanhai", player)
      end
    end
    if player.dead then return end
    if b then
      if player:getMark(lanhai.name) < 3 then
        room:addPlayerMark(player,lanhai.name,1)
        room:changeMaxHp(player,1)
      end
      if not player.dead and player:isWounded() then
        room:recover { num = 1, skillName = lanhai.name, who = player, recoverBy = player}
      end
    end
  end,
})

return lanhai